When you finish using a component, you must close your connection to that component. Use the CloseComponent function to close the connection. For example, this code calls the application-defined procedure MyDrawAnOval (see Listing 4 ), which opens a connection to a drawing component and uses that component to draw an oval. This code closes the oval drawer component after it is finished using it.
VAR
aDrawOvalComp: ComponentInstance;
result: OSErr;
MyDrawAnOval(aDrawOvalComp); {open component and draw an oval}
result := DrawerErase(aDrawOvalComp); {erase the oval}
result := CloseComponent(aDrawOvalComp); {close the component}